package com.zh.sys.controller;

import com.zhang.entity.Employee;
import com.zhang.entity.Examine;
import com.zhang.entity.Feedback;
import com.zhang.entity.Retuntity;
import com.zh.sys.service.EmployeeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 96199
 * @className: EmployController
 * @description:
 * @date: 2021/6/24 15:34
 * @version: 0.1
 * @since: jdk1.8
 */
@RestController
@RequestMapping("/user")
public class EmployController {

    @Resource
    private EmployeeService employeeService;

    @PutMapping
    public Retuntity insertUser(@RequestBody Employee employee){
        employeeService.insert(employee);
        return Retuntity.success("添加成功");
    }

    @PutMapping("/{tid}/{uid}")
    public Retuntity updateUser(@PathVariable("uid") String uid, @PathVariable("tid") String tid){
        employeeService.updateUser(uid,tid);
        return Retuntity.success("导师分配成功");
    }

    @GetMapping("/{uid}")
    public Employee getEm(@PathVariable("uid") String uid){
        return employeeService.queryById(Long.valueOf(uid));
    }

    @GetMapping("/Employ/allEm")
    public List<Employee> getEms(){
        Employee employee = new Employee();
        employee.setIsDel(0);
        employee.setIsUpdate(1);
        employee.setIsOfficial(0);
        return employeeService.queryAll(employee);
    }

    @PutMapping("/updata/{uid}")
    public Retuntity updata(@PathVariable("uid") String uid){
        return employeeService.updateTeacher(uid);
    }

    @PostMapping("/queryEm/{tid}")
    public  Retuntity queryEm(@PathVariable("tid") String tid){
        Employee employee = new Employee();
        employee.setTid(Long.valueOf(tid));
        List<Employee> employees = employeeService.queryAll(employee);
        return new Retuntity(employees,200,"查询成功");
    }



    @PostMapping("/getEm/one")
    public Employee getEmPl(@RequestBody Employee employee){
        return employeeService.getEmPl(employee);
    }
}
